let host = 'http://192.168.2.101:8081'

/**
 * 数据请求
 * @param {*} url 接口地址
 * @param {*} data 携带数据
 * @param {*} method 请求方式
 */
function request(url, method = 'POST', data = {}) {
	// let userinfo = wx.getStorageSync('userinfo')
	// if (userinfo) {
	// 	data.openid = userinfo.openid
	// }
	// 请求数据
	return new Promise((resolve, reject) => {
		wx.request({
			url: url,
			data,
			method,
			success: res => resolve(res.data),
			fail: err => reject(err)
		})

	})
}
/**
 * 文件上传
 * @param {*} filePath 文件本地路径
 * @param {*} path 上传路径
 */
function upload(path, filePath) {
	return new Promise((resolve, reject) => {
		// let header = {
		// 	'Content-Type': 'multipart/form-data'
		// }
		// let userinfo = wx.getStorageSync('userinfo')
		// if (userinfo) {
		// 	header.Authorization = 'Bearer ' + userinfo.authToken
		// }
		wx.uploadFile({
			filePath: filePath,
			name: 'file',
			url: host + path,
			success: res => {
				resolve(res.data)
			},
			fail: err => {
				reject(err)
			}
		})
	})
}

module.exports = {
	bannerList: [{
		title: "banner 1",
		src: "https://homesitetask.zbjimg.com/homesite/task/5.jpg/origine/04fd2aff-ae08-4211-852f-08ad30f8b27e",
		url: ""
	}, {
		title: "banner 2",
		src: "https://www.huierweb.com/uploads/2024/11/191650228475.jpeg",
		url: ""
	}, {
		title: "banner 3",
		src: "https://img0.baidu.com/it/u=2563985038,3161520518&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500",
		url: ""
	}],
	functionList: [{
		name: "个性娱乐",
		list: [{
			name: "坤德",
			icon: "/images/function_icon/kunde.png",
			event: {
				name: "toPage",
				value: "/pages/happyTools/pages/kunDe/index"
			},
			showFirstPage: true,
			enabled: true
		}, {
			name: "插电充钱",
			icon: "/images/function_icon/wechatMoney.png",
			event: {
				name: "toPage",
				value: "/pages/happyTools/pages/wechatMoney/index"
			},
			showFirstPage: true,
			enabled: true
		}, {
			name: "夜店手灯",
			icon: "/images/function_icon/yedianLightIcon.png",
			event: {
				name: "toPage",
				value: "/pages/happyTools/pages/handLamp/index"
			},
			showFirstPage: true,
			enabled: true
		}, {
			name: "手持弹幕",
			icon: "/images/function_icon/damuicon.png",
			event: {
				name: "toPage",
				value: "/pages/happyTools/pages/bulletChat/index"
			},
			showFirstPage: true,
			enabled: true
		}, {
			name: "闪光灯",
			icon: "/images/function_icon/mobileFlash.png",
			event: {
				name: "toPage",
				value: "/pages/happyTools/pages/mobileFlash/index"
			},
			showFirstPage: true,
			enabled: true
		}, {
			name: "理发器",
			icon: "/images/function_icon/hairClipper.png",
			event: {
				name: "toPage",
				value: "/pages/happyTools/pages/hairClipper/index"
			},
			showFirstPage: true,
			enabled: true
		}, 
		// {
		// 	name: "数字2048",
		// 	icon: "/images/function_icon/2048.png",
		// 	event: {
		// 		name: "toPage",
		// 		value: "/pages/happyTools/pages/2048NumberGame/index"
		// 	},
		// 	showFirstPage: true,
		// 	enabled: true
		// }
	]
	}, {
		name: "日常工具",
		list: [{
			name: "圆形时钟",
			icon: "/images/function_icon/nowtime.jpg",
			event: {
				name: "toPage",
				value: "/pages/dailyTools/pages/circleTime/index"
			},
			showFirstPage: true,
			enabled: true
		}, {
			name: "指南针",
			icon: "/images/function_icon/compassIcon.png",
			event: {
				name: "toPage",
				value: "/pages/dailyTools/pages/compass/index"
			},
			showFirstPage: true,
			enabled: true
		}, {
			name: "艺术签名",
			icon: "/images/function_icon/artisticSignature.png",
			event: {
				name: "toPage",
				value: "/pages/dailyTools/pages/artisticSignature/index"
			},
			showFirstPage: true,
			enabled: true
		}, {
			name: "色盲测试",
			icon: "/images/function_icon/colorBlindness.png",
			event: {
				name: "toPage",
				value: "/pages/dailyTools/pages/colorBlindnessTest/index"
			},
			showFirstPage: true,
			enabled: true
		}, {
			name: "日期倒计时",
			icon: "/images/function_icon/countdown.jpeg",
			event: {
				name: "toPage",
				value: "/pages/dailyTools/pages/countdown/index"
			},
			showFirstPage: true,
			enabled: true
		}, ]
	}, {
		name: "计算测绘",
		list: [{
			name: "贷款计算",
			icon: "/images/function_icon/lilv.png",
			event: {
				name: "toPage",
				value: "/pages/calculationTools/pages/interestRate/index"
			},
			showFirstPage: false,
			enabled: true
		}, {
			name: "计算器",
			icon: "/images/function_icon/jisuanqi.png",
			event: {
				name: "toPage",
				value: "/pages/calculationTools/pages/calculator/index"
			},
			showFirstPage: false,
			enabled: true
		}, {
			name: "直尺",
			icon: "/images/function_icon/straightIcon.png",
			event: {
				name: "toPage",
				value: "/pages/calculationTools/pages/straight/index"
			},
			showFirstPage: false,
			enabled: true
		}, {
			name: "量角尺",
			icon: "/images/function_icon/liangjiaoqiIcon.png",
			event: {
				name: "toPage",
				value: "/pages/calculationTools/pages/protractor/index"
			},
			showFirstPage: false,
			enabled: true
		}, {
			name: "亲戚称呼",
			icon: "/images/function_icon/titleCalculation.jpeg",
			event: {
				name: "toPage",
				value: "/pages/calculationTools/pages/titleCalculation/index"
			},
			showFirstPage: false,
			enabled: true
		}, {
			name: "BMI计算",
			icon: "/images/function_icon/BMI.png",
			event: {
				name: "toPage",
				value: "/pages/calculationTools/pages/bmi/index"
			},
			showFirstPage: false,
			enabled: true
		}]
	}, {
		name: "图片处理",
		list: [{
			name: "宫格切图",
			icon: "/images/function_icon/gong_ge.png",
			event: {
				name: "toPage",
				value: "/pages/imageTools/pages/gongGe/index"
			},
			showFirstPage: false,
			enabled: true
		}, {
			name: "搜图",
			icon: "/images/function_icon/search_image.png",
			event: {
				name: "toPage",
				value: "/pages/imageTools/pages/baiduImages/index"
			},
			showFirstPage: false,
			enabled: true
		}, {
			name: "图片裁剪",
			icon: "/images/function_icon/imageCut.jpeg",
			event: {
				name: "toPage",
				value: "/pages/imageTools/pages/imageCut/index"
			},
			showFirstPage: false,
			enabled: true
		}, {
			name: "图片压缩",
			icon: "/images/function_icon/imageCompression.jpeg",
			event: {
				name: "toPage",
				value: "/pages/imageTools/pages/imageCompression/index"
			},
			showFirstPage: false,
			enabled: true
		}, {
			name: "国旗头像",
			icon: "/images/function_icon/flag.jpeg",
			event: {
				name: "toPage",
				value: "/pages/imageTools/pages/nationalFlag/index"
			},
			showFirstPage: false,
			enabled: true
		}]
	}, {
		name: "音频处理",
		list: [{
			name: "音乐在线",
			icon: "/images/function_icon/online_music.png",
			event: {
				name: "toPage",
				value: "/pages/audioTools/pages/onlineMusic/index"
			},
			showFirstPage: false,
			enabled: true
		}, ]
	}, {
		name: "视频处理",
		list: []
	}],
	personalFunctionList: [{
		position: "top",
		list: [{
			name: "赚积分",
			iconClass: "cuIcon-choicenessfill",
			event: {
				name: "developing",
				value: ""
			},
			enabled: true
		}, {
			name: "积分兑换",
			iconClass: "cuIcon-sponsorfill",
			event: {
				name: "developing",
				value: ""
			},
			enabled: true
		}]
	}, {
		position: "bottom",
		list: [{
			name: "在线客服",
			iconClass: "cuIcon-choicenessfill",
			openType: "contact",
			enabled: true
		}, {
			name: "关注服务号",
			iconClass: "cuIcon-weixin",
			event: {
				name: "showWeixinCode",
			},
			enabled: true
		}, {
			name: "打小报告",
			iconClass: "cuIcon-markfill",
			// event: {
			// 	name: "toPage",
			// 	value: "/pages/feedback/index"
			// },
			openType:"feedback",
			enabled: true
		}, {
			name: "分享好友",
			iconClass: "cuIcon-forwardfill",
			openType: "share",
			enabled: true
		}]
	}],
	/**
	 * 百度搜图接口。PC端
	 * 关联词查询
	 */
	async baiduSugrec(word) {
		try {
			let url = 'https://www.baidu.com/sugrec'
			return await request(url, 'GET', {
				'cb': '',
				'ie': 'utf - 8',
				'wd': word,
				'prod': 'open_image',
				't': '0.1322693956927954',
				'_': new Date().getTime(),
			})
		} catch (error) {
			return error
		}
	},
	/**
	 * 百度接口——搜图
	 * @param {*} word 搜索词
	 * @param {*} numOfLoad 加载数量
	 */
	async baiduSearch(word, numOfLoad) {
		try {
			let url = 'https://image.baidu.com/search/acjson'
			return await request(url, 'GET', {
				'tn': 'resultjson_com',
				'logid': 11234017027830083799,
				'ipn': 'rj',
				'ct': 201326592,
				'is': '',
				'fp': 'result',
				'fr': '',
				'word': word,
				'queryWord': word,
				'cl': 2,
				'lm': -1,
				'ie': 'utf-8',
				'oe': 'utf-8',
				'adpicid': '',
				'st': '-1',
				'z': '',
				'ic': '',
				'hd': '',
				'latest': '',
				'copyright': '',
				's': '',
				'se': '',
				'tab': '',
				'width': '',
				'height': '',
				'face': '0',
				'istype': '2',
				'qc': '',
				'nc': '1',
				'expermode': '',
				'nojc': '',
				'isAsync': '',
				'pn': numOfLoad,
				'rn': 30,
				'gsm': 'c',
			})
		} catch (error) {
			return error
		}
	},
	/**
	 * 
	 * @param {*} fsize 字体大小
	 * @param {*} font 字体类型
	 * @param {*} text 文字内容
	 * @param {*} mirror 字体镜像。yes / no
	 * @param {*} color 字体上色
	 * @param {*} vcolor 字体下色
	 * @param {*} bgcolor 背景颜色
	 * @param {*} alpha 字体渐变。yes / no
	 * @param {*} shadow 字体投影。yes / no
	 */
	async yiShuQianMing(fsize, font, text, mirror, color, vcolor, bgcolor, alpha, shadow) {
		try {
			return await request(`https://www.yishuzi.cn/qianming/image.png?fsize=${fsize}&font=${font}&text=${text}&mirror=${mirror}&color=${color}&vcolor=${vcolor}&bgcolor=${bgcolor}&alpha=${alpha}&output=png&spacing=4&shadow=${shadow}&transparent=no&icon=no&iconic=&top_spacing=5&left_spacing=6&icon_size=48`, 'GET')
		} catch (error) {
			return error
		}
	},
}